﻿using ET.Monitor.DAL;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ET.Monitor.Model
{
    public class PersonnelModel
    {
        string grp = "", uid = "", name = "", pwd = "", st = "", et = "", org = "", langu = "";
        PersonnelDAL dal = new PersonnelDAL();
        int count = 1;
        int pageIndex = 1;
        #region 构造方法
        public PersonnelModel()
        {
        }
        public PersonnelModel(string userId)
        {
            uid = userId;
        }
        public PersonnelModel(string userId, string password)
        {
            uid = userId;
            pwd = password;
        }
        public PersonnelModel(string userId, string sTime, string eTime)
        {
            uid = userId;
            st = sTime;
            et = eTime;
        }
        public PersonnelModel(string userId, int count, int pageIndex)
        {
            uid = userId;
            this.count = count;
            this.pageIndex = pageIndex;
        }
        int n = 0, i = 1;
        public PersonnelModel(string userId, string sTime, string eTime, int num, int inde)
        {
            uid = userId;
            st = sTime;
            et = eTime;
            n = num;
            i = inde;
        }
        string connect = "";
        DateTime time = new DateTime();
        public PersonnelModel(string userId, string conect, DateTime time)
        {
            uid = userId;
            this.connect = conect;
            this.time = time;
        }

        //public PersonnelModel(string userId, string userName, string userPsd, string userOrg, string userLangu, string userPhone, string userEmail)
        //{
        //    uid = userId; name = userName; pwd = userPsd; org = userOrg; langu = userLangu; phone = userPhone; email = userEmail;
        //}
        byte[] btImg = null; string btImgName = "";
        public PersonnelModel(string userGrp, string userId, string userName, string userPsd, string userOrg, string userLangu, string userPhone, string userEmail, byte[] bt, string btName)
        {
            grp = userGrp; uid = userId; name = userName; pwd = userPsd; org = userOrg; langu = userLangu; phone = userPhone; email = userEmail; btImg = bt; btImgName = btName;
        }
        #endregion

        #region 增加新的人员
        bool isAdd;
        public bool AddPersonnel
        {
            get { return dal.AddUser(grp, uid, name, pwd, org, langu, phone, email, btImg, btImgName); }
            set { isAdd = value; }
        }
        #endregion

        #region 编辑人员色
        bool isEdit;
        public bool EditPersonnel
        {
            get { return dal.EditUser(grp, uid, name, pwd, org, langu, phone, email, btImg, btImgName); }
            set { isEdit = value; }
        }
        #endregion
        #region 获取人员头像
        object isPhoto;
        public DataTable Photo
        {
            get { return dal.DownUserPhoto(uid); }
            set { isPhoto = value; }
        }
        #endregion


        #region 删除人员
        object isDel;
        public object DelPersonnel
        {
            get { return dal.DelUser(uid); }
            set { isDel = value; }
        }
        #endregion

        #region 用户关联组织机构
        bool addUserOrg;

        public bool AddUserOrg
        {
            get { return dal.AddUserRelateOrg(uid, pwd); }
            set { addUserOrg = value; }
        }
        #endregion

        #region 判断某个用户是否存在
        object objCheck;

        public object ObjCheck
        {
            get { return dal.CheckUser(uid, pwd); }
            set { objCheck = value; }
        }
        #endregion

        #region 获取用户姓名
        string userName;

        public string UserName
        {
            get { return dal.GetUserName(uid); }
            set { userName = value; }
        }
        #endregion

        #region 获取角色编码
        string group;

        public string Group
        {
            get { return dal.GetGroup(uid); }
            set { group = value; }
        }
        #endregion

        #region 组织机构编码
        string orgid;

        public string Orgid
        {
            get { return dal.GetOrgid(uid).ToString(); }
            set { orgid = value; }
        }
        DataTable ortiDt;

        public DataTable OrtiDt
        {
            get { return dal.GetOrgids(uid); }
            set { ortiDt = value; }
        }

        #endregion

        public bool DeleteUserOrg
        {
            get
            {
                return dal.DeleteUserRelateOrg(uid);
            }

            set
            {
                deleteUserOrg = value;
            }
        }
        bool deleteUserOrg;

        #region 取得所有用户的列表以及每个用户的角色ID
        DataTable allUserInfoWithGrp;
        public DataTable AllUserInfoWithGrp
        {
            get { return dal.GetAllUserWithGrpId(); }
            set { allUserInfoWithGrp = value; }
        }
        #endregion
        DataTable stationIds;

        public DataTable StationIds
        {
            get { return dal.GetStations(uid); }
            set { stationIds = value; }
        }

        DataTable stationInfo;
        public DataTable StationInfo
        {
            get
            {
                return dal.GetStations(uid, count, pageIndex);
            }

            set
            {
                stationInfo = value;
            }
        }

        #region 电站ID集合
        DataTable dtStation;

        public DataTable DtStation
        {
            get { return dal.GetStation(uid); }
            set { dtStation = value; }
        }

        #endregion

        #region Email
        string email;

        public string Email
        {
            get { return dal.GetEmail(uid); }
            set { email = value; }
        }
        #endregion

        #region Phonea
        string phone;

        public string Phone
        {
            get { return dal.GetPhone(uid); }
            set { phone = value; }
        }
        #endregion

        #region Task
        DataTable dtTask;

        public DataTable DtTask
        {
            get { return dal.GetTask(uid, st, et); }
            set { dtTask = value; }
        }

        DataTable dtTaskPage;
        public DataTable DtTaskPage
        {
            get { return dal.GetTaskPage(uid, st, et, n, i); }
            set { dtTaskPage = value; }
        }
        #endregion

        #region 获取电站信息 APP
        DataTable dtStationByUser;
        public DataTable DtStationByUser
        {
            get
            {
                return dal.GetStationByUser(uid);
            }

            set
            {
                dtStationByUser = value;
            }
        }
        #endregion

        #region 省份
        DataTable dtPrivince;
        public DataTable DtPrivince
        {
            get
            {
                return dal.GetPrivince(uid);
            }

            set
            {
                dtPrivince = value;
            }
        }
        #endregion

        #region 用户操作记录
        bool blLog;

        public bool BlLog
        {
            get
            {
                return dal.AddLog(uid, connect, time);
            }

            set
            {
                blLog = value;
            }
        }
        #endregion

        #region 用户Log查询
        int logCount;
        public int LogCount
        {
            get
            {
                return dal.GetLogTotalCount(uid, st, et);
            }

            set
            {
                logCount = value;
            }
        }
        
        DataTable dtLog;
        public DataTable DtLog
        {
            get
            {
                return dal.GetLog(n, i, uid, st, et);
            }

            set
            {
                dtLog = value;
            }
        }
        #endregion
    }
}
